// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'

Vue.config.productionTip = false

// 长按事件
Vue.directive('longtap', {
  inserted: function (el, binding) {
    var timer
    var counter = 0
    el.addEventListener('touchstart', function () {
      timer = setInterval(function () {
        if (counter > 2) {
          binding.value()
          counter = 0
        } else {
          counter++
        }
      }, 200)
    })
    el.addEventListener('touchend', function () {
      clearInterval(timer)
      counter = 0
    })
  }
})

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  template: '<App/>',
  components: {App}
})
